package com.itheima.controller;

import com.itheima.domain.Huangzhe;
import com.itheima.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    //查询所有患者
    @RequestMapping("/findAll")
    public ModelAndView findAll(ModelAndView modelAndView) {
        List<Huangzhe> huangzheList = productService.findAll();
        modelAndView.addObject("huangzheList", huangzheList);
        modelAndView.setViewName("patients-list");
        return modelAndView;
    }

    //根据用户名称查询(模糊查询)
    @RequestMapping("/findByTiaojian")
    public ModelAndView findByTiaojian(String name, ModelAndView modelAndView) {
        List<Huangzhe> huangzheList = productService.findByTiaojian(name);
        modelAndView.addObject("huangzheList", huangzheList);
        modelAndView.setViewName("patients-list");

        return modelAndView;
    }

}
